<%@ page contentType="text/html; charset=utf-8" language="java"  errorPage="" %>
<%@ page import="com.netscenery.yang.model.YangList" %>
<%@page import="com.netscenery.yang.model.Env"%>
<%@ page import="operate.OperateType"%>
<%@page import="offer.GetDataSource"%>
<%@page import="offer.SessionObj"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
YangList yangList = new YangList(new Env(),"MyList");
//获取结点对象
Object itemNode = request.getAttribute("itemNode");
Object opType   = request.getAttribute("opType"); //获取操作对象
if( null != itemNode){
	yangList = (YangList)itemNode;
}
//Session ModuleStatus control
SessionObj sessionObj = (SessionObj)request.getSession().getAttribute("sessionObj");
String control_disabled = "";
if(!sessionObj.getModuleStatus().toString().equalsIgnoreCase("EDITING")){
 	control_disabled ="disabled='disabled'";
}
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>YangList</title>
    <meta http-equiv="Pragma" content="no-cache" />
    <meta http-equiv="Cache-Control" content="no-cache" />
    <meta http-equiv="Expires" content="0" />
	<link rel="stylesheet" type="text/css" href="<%=basePath%>/css/items.css" />
	<link rel="stylesheet" type="text/css" href="<%=basePath%>/css/subItems.css" />
	<link rel="stylesheet" type="text/css" href="<%=basePath%>/css/Tab.css" />
	<link rel="stylesheet" type="text/css" href="<%=basePath%>/css/yangList.css" />
    <script type="text/javascript"  src="<%=basePath%>/jstree-v.pre1.0/_lib/jquery.js"></script>
    <script type="text/javascript"  src="<%=basePath%>/js/getElementPos.js"></script>
    <script type="text/javascript"  src="<%=basePath%>/js/YangList.js"></script>
    <script type="text/javascript"  src="<%=basePath%>js/StringUtil.js"></script>
    <script type="text/javascript"  src="<%=basePath%>js/IfFeature.js"></script>
    <script type="text/javascript"  src="<%=basePath%>js/Tab.js"></script>
</head>
<body class="body">
<script type="text/javascript">
  function bodyLoad(){
    <% if( (null != itemNode) 
        &&  (!opType.toString().equalsIgnoreCase(OperateType.LOAD))){ 
       		 if(opType.toString().equalsIgnoreCase(OperateType.ADD)
    				|| opType.toString().toString().equalsIgnoreCase(OperateType.MODIFY_INCLUDE_NAME)){ 
    %>
	   		 	 //新增节点时，重新加载�
	   		 	 parent.reloadTreeWithNode(document.getElementById("nodeId").value);
    <%   		 } %>
			 $("#opNoticeSpan").html("操作成功");
   		 	 setTimeout(function(){$("#opNoticeSpan").html("")},3000);
   <% }%>
  }
  $(document).ready(function(){
   		if( $("ul#ListChooseKeys_ul").html().trim().length == 0){
   			$("#setKeyButton").attr("disabled","disabled");
   			$("#setUniqueButton").attr("disabled","disabled");
   			$("#setSelectsButton").attr("disabled","disabled");
   		}
   		$("#submitButton").click(function(){
	 	     $(":input").css("border-color","");
		     if($("#_name").val().trim().length == 0){
		        $("#_name").css("border-color","red");
		        alert("name 不能为空�");
		        return;
		     }
		     //名字验证
		     if(!nameVerify($("#_name").val().trim())){
		     	return;
		     }
		    document.getElementById("yangListForm").submit(); 
		});
	    tabLaod();
		load_Feature();
		bodyLoad();
   });
 	//用于保存节点中的If Feature name的列�biao表与IfFeature.js配合使用
 	var availableFeatures = "<%= GetDataSource.GetAvailableIfFeatureList(yangList)%>";
 	var currNodeFeatures  = "<%= GetDataSource.GetCurrNodeIfFeatureList(yangList)%>";
</script>
 <!-- ***************************************** Tab Navigate Begin **************************************  -->
 <div class="navTitle" style="display:none;">
   <ul id="navTabTitle">
     <li id="mainContent_ico" onclick="showThis('mainContent')">Leaf Main Content</li>
     <li id="type_ico"><span onclick="showThis('type')">Type Edit</span><img onclick="closeTab('type')" class='TitleLiImg' width='10' height='16' src='<%=basePath %>/images/delete.png' /></li>
     <!--  
     <li id="mimInfo_ico"><span onclick="showThis('mimInfo')">MimInfo Edit</span><img onclick="closeTab('mimInfo')" class='TitleLiImg' width='10' height='16' src='<%=basePath %>/images/delete.png' /></li>
   	 -->
   </ul>
   <div style="clear:both;"></div>
 </div>
 <!--  
 <div id="mimInfo_tab"  style="display:none;padding:0px;margin:0px;max-height:560px;height:560px;">
 <iframe width="100%" id="MimInfo_Iframe" name="MimInfo_Iframe"  height=100% border="0" frameborder="0" src=""  ></iframe>
 </div>
 -->
 <!-- ***************************************** Tab Navigate End   **************************************  -->
 <div id="mainContent_tab" class="" style="padding:0px;margin:0px;">
 <!-- ****************************************************************************************************** -->
 <form id="yangListForm" method="post" action="<%=basePath %>YangListOpreateServlet" class="IndexFormStyle" >
   <input type="hidden"  id="nodeId" name="nodeId" value="<%=request.getAttribute("nodeId") %>"  />
   <div id="TableContent" class="tableContent" >
        <div class="itemTitle">
	        The YangList [<%=yangList.getName() %>] information 
	    </div>
   	   <div class="itemDiv">
	     <span class="textSpan">&nbsp;List name:</span>
	     <input class="inputText" id="_name" name="_name" value="<%=yangList.getName()%>"  readonly="readonly"/>
	   </div>
	   <div class="itemDiv">
	   	 <% if(!yangList.isConfig()){ %>
          &nbsp;<input type="checkbox" id="isConfig" name = "isConfig"  value="true" />Config
         <%} else{%> 
          &nbsp;<input type="checkbox" id="isConfig" name = "isConfig" checked="checked" value="true" />Config
         <%}%> 
	   </div>
	   <div class="itemDiv">
	     <span class="textSpan">&nbsp;Key:</span>
	      <input class="inputText" id="keysEx" name="keysEx" value="<%=yangList.getKey()==null?"":yangList.getKey().toString()%>" readonly="readonly"  />
          <input type="button" id="setKeyButton" value = "Set key" readonly="readonly" onclick="SelectKeys('keysEx')" />
          <span class="notNullSpan">*</span>
       </div>
	   <div class="itemDiv">
	     <span class="textSpan">&nbsp;Uniques:</span>
	     <input class="inputText" id="uniquesEx" name="uniquesEx" value="<%=yangList.getUnique(0)==null?"":yangList.getUnique(0).toString() %>" readonly="readonly"  />
	     <input type="button" id="setUniqueButton" value = "Set Uniques" readonly="readonly" onclick="SelectKeys('uniquesEx')" />
       </div>
	   <div class="itemDiv">
	     <span class="textSpan">&nbsp;Min-elements:</span>
	     <input class="inputText" id="minElements" name="minElements" value="<%=yangList.getMinElements()==0?"":yangList.getMinElements()%>"  />
	   </div>
	   <div class="itemDiv">
	     <span class="textSpan">&nbsp;Max-elements:</span>
	     <input class="inputText" id="maxElements" name="maxElements" value="<%=yangList.getMaxElements()==0?"":yangList.getMaxElements()%>"  />
	   </div>
	   <div class="itemDiv">
	     <span class="textSpan">&nbsp;Status:</span>
	     <select style="width:305px;   height:23px;"   class="inputSelect" id="_status" name="_status">
          <% for(int i = 0 ; i < GetDataSource.getStatusList().length ; i++ ){ %>
          <%     if(yangList.getStatus().getStatus().equalsIgnoreCase(GetDataSource.getStatusList()[i])){ %>  
                    <option  value="<%= GetDataSource.getStatusList()[i]%>" selected="selected"><%=GetDataSource.getStatusList()[i] %></option>
          <%     }else{ %> 
                    <option  value="<%= GetDataSource.getStatusList()[i]%>" ><%=GetDataSource.getStatusList()[i] %></option>   
          <%     }
             }   %>
          </select>
	   </div>
	   
	   <!-- ***********************If Feature HTML part     Begin *************************************** -->
	   <input type="hidden" id="featureParam" name="featureParam" value="" />
	   <div id="If_Feature_Content" class="itemDiv">
	       
	   </div>
	   <!-- ***********************If Feature HTML part     End ***************************************** -->
	   <!--  
	   <div class="itemDiv">
		   <span class="textSpan">&nbsp;MimInfo:</span>
           <input type="button" id="_mimInfoEdit" value = "Edit MimInfo"  onclick="Show_MimIfoEdit()" />
	   </div>
	   <div id="SelectContainer" class="itemDiv">
	   
	   		<div class="rangeItem">
		     	<span class="textSpan">&nbsp;Selects:</span>
	     		<input class="inputText"  name="selects" value="" readonly="readonly" />
		     	<a href='#' class='rangeRemove' onclick="Select_Delete(this)" ><img class='buttonBcImg' width='25' src='<%=basePath%>/images/delete.png' /></a>
	     	</div>
	  
	   		<div class="rangeItem">
		     	<span class="textSpan">&nbsp;Selects:</span>
	     		<input class="inputText" id="selects_1" name="selects" value="" readonly="readonly" />
	     		<input type="button" id="setSelectsButton" value = "Set"  onclick="SelectKeys('selects_1')" />
		     	<a href='#' class='rangeRemove' onclick="Select_Delete(this)" ><img class='buttonBcImg' width='25' src='<%=basePath%>/images/delete.png' /></a>
		     	<a href='#' class='rangeAdd' onclick='Select_Add()' ><img class='buttonBcImg' width='25' src='<%=basePath%>/images/add.png' /></a>
	     	</div>
	   </div>
	    -->
	   <div class="itemDiv">
	   		<span class="textSpan">&nbsp;Description:</span><br/>
	    	<textarea class="textArea"  id="description" name="description"><%=yangList.getDescription()==null?"":yangList.getDescription() %></textarea>
	   </div>

	   <div class="itemDiv">
	   		<span class="textSpan">&nbsp;Reference:</span><br/>
	    	<textarea class="textArea"  id="reference" name="reference"><%=yangList.getReference()==null?"":yangList.getReference() %></textarea>
	   </div>
	   
   </div>
   <div id="submitContent" class="submitContent">
     <span id="opNoticeSpan" style="color:red;" ></span>
     <span class="textSpan">&nbsp;</span>
     <input type="button" id="submitButton" <%=control_disabled %> value="Apply"  />
   </div>
   </form>
   <!-- ****************************************************************************************************** -->
 </div>
 
  <!-- *****************************ListChooseKeys Begin************************************************** -->
    <div id="ListChooseKeys" class="ListChooseKeys" style="left:0; top:0; display:none;" >
      <div id="selectKeysTitle" class="selectKeys">
        <div class="floatLeft">Select Keys</div>
        <div class="floatRight">
            <a href="javascript:void(0);" class="window_close" id="window_close" title="close">close</a>
        </div>
        <div style="clear:both"></div>
      </div>
      <ul id="ListChooseKeys_ul">
      <% if(null != yangList.getSons()) { %>
	      <% for(int i = 0; i < yangList.getSonsNumber(); i++ ) { %>
	      	  <li>
	      	     <input type="checkbox" id="keySte_<%=i %>" name="keySte" value = "<%=yangList.getSon(i).getName() %>" readonly="readonly" />
	      	     <span><%=yangList.getSon(i).getName() %></span>
	      	  </li>
	      <% } %>
      <% } %>
      </ul>
      <div style="clear:both;"></div>
      <div id="selectKeysButton" >
         <input type="hidden" id="curr_ItemID" name="curr_ItemID" value="" />
         <input type="button" id="selectKey_OK" value="OK" class="inputButton" />
         <input type="button" id="selectKey_Cancel" value="Cancel" class="inputButton" />
      </div>
   </div>
  <!-- *****************************ListChooseKeys End************************************************** -->
    
</body>
</html>